<template>
  <div class="map-container">
    <div id="load" v-if="loading">
      <div class="load_img"><!-- 加载动画 -->
        <img class="jzxz1" :src="require('@/assets/images/property/jzxz1.png')">
        <img class="jzxz2" :src="require('@/assets/images/property/jzxz2.png')">
      </div>
    </div>
    <div class="head_top">
      <div style="display: flex;padding-top: 15px;">
        <div class="left-top-title-bg" style="width: 30%;text-align: center;">
          <img :src="require('@/assets/images/property/ksh31.png')">
        </div>
        <div style="width: 40%;color:white;font-family: yjsz;font-size: 40px;text-align: center;">
          <span >{{dateViewTitle}}</span>
        </div>
        <div class="right-top-title-bg" style="width:30%;text-align: center;">
          <img :src="require('@/assets/images/property/ksh32.png')">
        </div>
      </div>
    </div>
    <div class="visual" v-if="!loading">
      <div class="visual_left">
        <div class="visual_box">
          <div class="visual_title">
            <span>收 费  统 计</span>
            <img :src="require('@/assets/images/property/ksh33.png')">
          </div>
          <div class="visual_chart" id="main1">
            <NengHaoBar></NengHaoBar>
          </div>
        </div>
        <div class="visual_box">
          <div class="visual_title">
            <span>四保一服设备预警</span>
            <img :src="require('@/assets/images/property/ksh33.png')">
          </div>
          <div class="visual_chart" id="main2">
            <SiBaoYiFu></SiBaoYiFu>
          </div>
        </div>
        <div class="visual_box">
          <div class="visual_title">
            <span>设 备 预 警</span>
            <img :src="require('@/assets/images/property/ksh33.png')">
          </div>
          <div class="visual_chart sfzcll">
            <a></a>
            <a></a>
            <a></a>
            <div class="sfzcll_pos_box">
              <div class="sfzcll_box">
                <div class="sfzcll_smallBk">
                  <div class="ygl">
                    <span>强电设备</span>
                  </div>
                </div>
                <div class="sfzcll_smallBk">
                  <div class="ygl">
                    <span>报警952次</span>
                  </div>
                </div>
                <div class="sfzcll_smallBk">
                  <div class="ygh">
                    <span>已消除949次</span>
                  </div>
                </div>
                <div class="clear"></div>
              </div>
              <div class="sfzcll_box">
                <div class="sfzcll_smallBk">
                  <div class="ygl">
                    <span>弱电设备</span>
                  </div>
                </div>
                <div class="sfzcll_smallBk">
                  <div class="ygl">
                    <span>报警1952次</span>
                  </div>
                </div>
                <div class="sfzcll_smallBk">
                  <div class="ygh">
                    <span>已消除1892次</span>
                  </div>
                </div>
                <div class="clear"></div>
              </div>
              <div class="sfzcll_box">
                <div class="sfzcll_smallBk">
                  <div class="ygl">
                    <span>其他设备</span>
                  </div>
                </div>
                <div class="sfzcll_smallBk">
                  <div class="ygl">
                    <span>报警2212次</span>
                  </div>
                </div>
                <div class="sfzcll_smallBk">
                  <div class="ygh">
                    <span>已消除2210次</span>
                  </div>
                </div>
                <div class="clear"></div>
              </div>
            </div>

          </div>
        </div>
      </div>
      <div class="visual_con">
        <div class="visual_conTop">
          <div class="visual_conTop_box visual_conTop1">
            <div>
              <h3>项 目 数 量</h3>
              <p>213</p>
              <div class="conTop_smil">
                <a class="xd">个</a>
              </div>
            </div>
          </div>
          <div class="visual_conTop_box visual_conTop2">
            <div>
              <h3>管 理 面 积</h3>
              <p>1980</p>
              <div class="conTop_smil">
                <a class="xd">万平方米</a>
              </div>
            </div>
          </div>
          <div class="visual_conTop_box visual_conTop1">
            <div>
              <h3>户  数</h3>
              <p>23</p>
              <div class="conTop_smil">
                <a class="xd">万户</a>
              </div>
            </div>
          </div>
          <div class="visual_conTop_box visual_conTop2">
            <div>
              <h3>服务人员数量</h3>
              <p>3891</p>
              <div class="conTop_smil">
                <a class="xd">人</a>
              </div>
            </div>
          </div>
          <div class="clear"></div>
        </div>
        <div class="visual_conBot">
          <img class="visual_conBot_l" :src="require('@/assets/images/property/ksh42.png')">
          <img class="visual_conBot_2" :src="require('@/assets/images/property/ksh43.png')">
          <img class="visual_conBot_3" :src="require('@/assets/images/property/ksh44.png')">
          <img class="visual_conBot_4" :src="require('@/assets/images/property/ksh45.png')">
          <div class="visual_chart_text">
            <h1>全国项目大数据分析平台</h1>
          </div>
          <div class="visual_chart" id="main8">
            <ChartMap></ChartMap>
          </div>
          <div class="visual_conBot_bot">
            <div class="visualSssf_left">
              <h3>今日实时收费</h3>
              <a style="display:block;">全国数据</a>
              <a>北京</a>
              <a>重庆</a>
              <a>天津</a>
              <a>海南</a>
              <a class="active">山东</a>
              <a>江苏</a>
              <a>内蒙</a>
              <a>河南</a>
              <a>辽宁</a>
              <a>甘肃</a>
              <a>黑龙江</a>
              <a>新疆</a>
            </div>
            <div class="visualSssf_right">
              <div class="visualSssf_right_box" id="main5"></div>
              <div class="visualSssf_right_box" id="main6"></div>
              <div class="visualSssf_right_box" id="main7"></div>
            </div>
            <div class="clear"></div>
          </div>
        </div>
      </div>
      <div class="visual_right">
        <div class="visual_box">
          <div class="visual_title">
            <span>本月发生事件</span>
            <img :src="require('@/assets/images/property/ksh33.png')">
          </div>
          <div class="swiper-container visual_swiper1 visual_chart">
            <div class="swiper-wrapper">
              <div class="swiper-slide" id="main3">
                <MonthEvent></MonthEvent>
              </div>
<!--              <div class="swiper-slide" id="main31"></div>-->
            </div>
          </div>
        </div>
        <div class="visual_box visualSfzsfl">
          <div class="visual_title">
            <span> 工  单  预  警  </span>
            <img :src="require('@/assets/images/property/ksh33.png')">
          </div>
          <div class="visual_chart" id="main9"></div>
<!--          <div class="marquee-content" :class="{ 'animate-marquee': animate }">-->
<!--            <p>这是需要滚动的文字内容 {{ text }}</p>-->
<!--          </div>-->
<!--          <div class="marquee-content" :class="{ 'animate-marquee': animate }">-->
<!--          visual_table-->
          <div class="visual_table ">
            <div class="visual_table marquee" @mouseenter="enterMar()" @mouseleave="leaveMar()">
              <div :class="{ 'marquee-up': isUp }">
                <el-row class="marquee-text" v-for="(item, index) in repairRecords" :key="index">
                  <el-col :span="4">{{item.estateName}}</el-col>
                  <el-col :span="4">{{ item.estateName}}</el-col>
                  <el-col :span="4" v-if="item.checkType == 0">公共区域</el-col>
                  <el-col :span="4" v-if="item.checkType == 1">有偿报修</el-col>
                  <el-col :span="12">{{ item.content}}</el-col>
                </el-row>
              </div>
            </div>
          </div>
        </div>
        <div class="visual_box">
          <div class="visual_title">
            <span>收 费 率 排 行 </span>
            <img :src="require('@/assets/images/property/ksh33.png')">
          </div>
          <div class="swiper-container visual_swiper2 visual_chart">
            <div class="swiper-wrapper">
              <div class="swiper-slide" id="main4">
                <PropertyJiaoFei></PropertyJiaoFei>
              </div>
<!--              <div class="swiper-slide" id="main41"></div>-->
            </div>
          </div>
        </div>
      </div>
      <div class="clear"></div>
    </div>

  </div>
</template>

<script>
import {getDateViewMapCharts, getPropertyDateViewMap, getPropertyRepairRecordDateViewMap} from "@/api/module/charts";

  import EmptyList from '@/components/Tool/index';
  const baseURL = process.env.VUE_APP_BASE_API;
  require('echarts/theme/macarons');
  export default {
    name: 'Map',
    components: {
      EmptyList,
      ProView:() => import('@/components/ElUi/Dialog/popview'),
      popBoxGroup:() => import('@/components/ElUi/Dialog/popBoxGroup'),
      PopOver: () => import('@/components/ElUi/Popover/index'),
      Clock: () => import('@/views/module/dataview/Echarts/clock'),
      Orders: () => import('@/views/module/dataview/Echarts/orders'),
      Users: () => import('@/views/module/dataview/Echarts/users'),
      DeviceData: () => import('@/views/module/dataview/Echarts/deviceData'),
      ChargerData: () => import('@/views/module/dataview/Echarts/chargerData'),
      Projects: () => import('@/views/module/dataview/Echarts/project'),
      JiaoFei: () => import('@/views/module/dataview/Echarts/jiaofei'),
      PropertyJiaoFei: () => import('@/views/module/dataview/Echarts/propertyJiaofei'),
      Duojing: () => import('@/views/module/dataview/Echarts/duojing'),
      ChartMap: () => import('@/views/module/dataview/Echarts/chartMap'),
      MonthEvent: () => import('@/views/module/dataview/Echarts/monthEvent'),
      NengHaoBar: () => import('@/views/module/dataview/Echarts/nengHaoBar'),
      SiBaoYiFu: () => import('@/views/module/dataview/Echarts/siBaoYiFu'),
    },
    data() {
      return {
        dateViewTitle:'',
        loading: true,
        //  时间
        date:new Date(),
        queryParams:{
          propertyId:undefined,
        },
        // public 文件夹
        publicPath: process.env.BASE_URL,
        //右侧菜单
        actMemu: {
          layerViewer:false,
          // 工作量
          workBox:false,
          window1:false,
          popBoxGroup:true,
        },
        dataPop: {
          windows:[false,false,false,false,false,false],
          popBoxGroup:true,
        },
        popBoxGroup:[true,true,true,true,true,true,false],
        popBoxGroupWindow:[false],
        currentUserId:0,
        centerBtns:[
          { type:'estate',name:'服务面积', icon:'estate_point.png', url:'',count:0,path:'/user/company/list', },
          { type:'charger',name:'缴费率', icon:'charger_point.png', url:'/terminal/check',count:0,path:'/device/list' },
          { type:'device',name:'用户量', icon:'device_point.png', url:'',count:0,path:'/user/customer/list' },
          { type:'mer',name:'服务项目',icon:'mer_point.png', url:'',count:0,path:'/mer/list' },
        ],
        estateList:[],
        position: 0,
        speed: 2, // 滚动速度，可根据需要调整
        text: '这是跑马灯效果，可以连续滚动文本内容。',
        animate: true,
        isUp: false,
        repairRecords:[],
        timer: null,
      }
    },
    computed:{},
    watch: {
      'actMemu.popBoxGroup':{
        handler(val) {
          let that = this;
          const length = this.popBoxGroup.length;//群组组件个数
          const setVisible = function (visible) {
            for (let index = 0; index < length; index++) {
              that.popBoxGroup[index] = visible;
            }
          };
          if (val) {
            setVisible(true);
          } else {
            setVisible(false)
          }
        }
      },
      popBoxGroup:{
        handler(val) {
          let tag = false;
          for (let item of val) {
            if (item) tag = true;
          }
          if (this.actMemu.popBoxGroup && !tag) this.actMemu.popBoxGroup = false
        }
      }
    },
    created() {
      var that = this;
      console.log('this.$route.query',this.$route.query);
      this.queryParams.propertyId = this.$route.query.pId ? this.$route.query.pId : 0;
      this.initData();
      this.initDataCharts();
    },
    mounted() {
      // this.startMarquee();
      this.timer = setInterval(this.scrollAnimate, 3000);
      setTimeout(() => {
        this.getRepairRecord();
      }, 10000);
    },
    destroyed() {
      clearInterval(this.timer);
    },
    methods: {
       scrollAnimate() {
          this.isUp = true;
          setTimeout(() => {
            this.repairRecords.push(this.repairRecords[0]);
            this.repairRecords.shift();
            this.isUp = false;
          }, 500);
        },

        enterMar() {
          clearInterval(this.timer);
        },
        leaveMar() {
          this.timer = setInterval(this.scrollAnimate, 3000);
        },
      initData(){
        var that = this;
        getPropertyDateViewMap(this.queryParams).then(response => {
          //获取当前物业的数据
          that.mapData = response.data;
          that.dateViewTitle = response.data.dateViewTitle;//
          that.estateList = response.data.estates;

          that.repairRecords = response.data.repairRecords;

          that.centerBtns[0].count = "";//response.data.estateCount;//
          that.centerBtns[1].count = response.data.chargerCountTotal;
          that.centerBtns[2].count = response.data.devicesCount;
          that.centerBtns[3].count = 3;//that.merCount;

          setTimeout(function () {

          },100);
          that.loading = false;
        });
      },
      getRepairRecord(){
        let that = this;
        getPropertyRepairRecordDateViewMap(this.queryParams).then(response => {
          //获取当前物业的数据
          that.repairRecords = response.data.repairRecords;
        });
      },
      startMarquee() {
        this.timer = setInterval(() => {
          this.position -= this.speed;
          // 当文字完全滚出容器时，重置位置
          const containerHeight = 200;
          const contentHeight = 380;
          if (Math.abs(this.position) >= contentHeight) {
            this.position = containerHeight;
          }
          console.log('this.position',this.position)
        }, 20);
      },
      stopMarquee() {
        clearInterval(this.timer);
      },
      initDataCharts(){
        var that = this;
      },
      handleTitle(type){
        this.switchMenu(type);
      },
      //中间地图
      initMap(lng,lat) {
        var that = this;
      },
      // 切换右侧菜单
      switchMenu(t_index){
        var that = this;
      },
    }
  }
</script>

<style lang='scss' scoped>
  @import '@/assets/styles/property/swiper.min.scss';
  @import '@/assets/styles/property/visual.scss';
  .map-container {
    position: relative;
    height:calc(100vh);
    width:100%;
    background: url('~@/assets/images/property/data08.png') no-repeat;
    background-size: 100% 100%;
  }

  //.marquee-container {
  //  height: 50px; /* 容器高度，可根据需要调整 */
  //  overflow: hidden;
  //}
  //
  //.marquee {
  //  position: relative;
  //  transition: top 0.2s linear;
  //}

  .marquee {
    height: 120px;
    text-align: center;
    overflow: hidden;

    &-up {
      transition: all 0.5s;
      transform: translateY(-40px);
    }

    &-text {
      line-height: 40px;
      color:#fff;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }


  .header {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 998;

    .header-bg {
      width: 100%;
      height: 4rem;
      background: url('~@/assets/images/header_bg.png') no-repeat;
      background-size: 100% 100%;
      text-align: center;
      display: flex;
      justify-content: center;
      cursor: pointer;
    }

    .header-title {
      font-size: 2.2rem;
      font-family: FZZYJW--GB1-0;
      font-weight: 600;
      /*color:white;*/
      background: -webkit-gradient(linear,left bottom,left top,color-stop(.41504%,#1dbaff),to(#f8f7ff));
      background: linear-gradient(0deg,#1dbaff .41504%, #fdfdff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      line-height: 1.85rem;
      letter-spacing: .4rem;
      margin-top: 1.6vh;
    }
  }

  #container{
    background-color: rgb(16, 36, 125) !important;
    background-image:none;
  }

  .top-panel{
    width: 30rem;
    height: 10rem;
  }

  .btnsRight {
    /*margin-left: auto;*/
    margin-left: 5%;
  }
  .left-panel{
    position: absolute;
    left:10px;
    top:4rem;
  }
  .right-panel{
    position: absolute;
    right:10px;
    top: 4rem;
  }


  .left-panel-bg{
    position: absolute;
    left:0;
    top:0;
    width: 100%;
    height: 100%;
    background-color: #0a3267;
    opacity: 0.8;
    border-radius: 10px;
    z-index: 0;
  }

  .centerBtn{
    position: absolute;
    top:5rem;
    left:27%;
    width:45%;
    /*height: 5rem;*/
    z-index: 1;
    text-align: center;
    .topBtn{
      cursor: pointer;
      margin-left: 1rem;
      padding: 1.4rem 1rem;
      background: url('~@/assets/images/view/view-btn-bg.png') no-repeat;
      background-size: 100% 100%;
    }
    .topBtn img{
      width: 1.6rem;
      height: 1.8rem;
      float: right;
    }
    .topBtn span{
      color: white;
      /*margin-left: 1rem;*/
      font-size: 1.1rem;
      line-height: 1.2rem;
      font-weight: bold;
      background: linear-gradient(  0deg , #fbffff 0.41504%, #b4eeff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    .count{
      /*margin-left: 0rem;*/
      padding: 0px 10px 20px;
      position: relative;
    }
    .title{
      color: white;
      margin: 0;
    }

  }


  .centerModule{
    position: absolute;
    text-align: center;
    background-color: #0c25b9;
    opacity: 0.7;
    height: 5rem;
    width: 90%;
    margin: 1rem;
    border-radius: 1rem;
    z-index:-1;
  }

  .centerModuleTxt{
    text-align: center;
    height: 5rem;
    width: 90%;
    line-height: 2.5rem;
    margin: 1rem;
    font-size: 22px;
    font-weight: bold;
    color:white;
    display: grid;
    z-index:1;
    cursor: pointer;
  }

  ::v-deep .el-table{
    color:white;
    background-color: unset;
  }
  ::v-deep .el-table tr{
    background-color: unset;
  }
  ::v-deep .el-table--enable-row-hover .el-table__body tr:hover>td{
    background-color: #959ba7 !important;
  }

  ::v-deep .el-table__header .el-table tr{
    background-color: unset;
  }
  ::v-deep .el-table__empty-text{
    color:white;
  }
  ::v-deep .el-tabs__item{
    color:white;
  }
  ::v-deep .el-tabs__item.is-active{
    color: #1890ff;
  }

  .order-list {
    height: 38rem;
    overflow: scroll;
    padding: 0.5rem 0.5rem;
    /*min-height: 11rem;*/
    white-space: nowrap;
    /*font-size: 0.8rem;*/
    font-size: 1rem;
    /*color: #1dbaff;*/
    color: white;
    background: linear-gradient(0deg, #1dbaff 0.41504%, #b4eeff);
    -webkit-background-clip: text;


    .order-list-item {
      padding: 0.4rem 0.3rem;
      /*border-bottom: 1px solid #0a7cf4;*/
      .line-span{
        font-size: 12px;
        color: white;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        -webkit-line-clamp: 4;
        /*max-height: 65px;*/
      }
    }
    .source-list-item {
      padding: 0.6rem 0.3rem;
      /*border-bottom: 1px solid #0a7cf4;*/
    }
    .btn-detail{
      cursor: pointer;
    }
  }

  .centerMap{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    //background: #0a386c;

    /*top: 11.5rem;*/
    /*left: 28%;*/
    /*width: 44%;*/
    /*height: 50%;*/
    /*background: #0a386c;*/
  }

  .bottomWarn{
    position: absolute;
    bottom: 1.5rem;
    left:23.5%;
    width:53%;
    height: 10rem;
    /*background: url('~@/assets/images/view/bottom_warn-bg.png') no-repeat;*/
    background-size: 100% 100%;
    text-align: center;
    .warn-item-header{
      color:white;
      padding: 0.3rem;
    }
    .warn-item{
      padding: 0.35rem;
      color:#9ED6F9;
    }
  }
  .amap-logo{
    display: none;//去掉高德地图logo
  }
  .amap-copyright {
    opacity:0;//去掉高德的版本号
  }

  .left-charts{
    position: absolute;
    left:10px;
    top: 15rem;
    width: 30rem;
    height: 72%;
    z-index: 100;
  }
  .orders-charts{
    position: relative;
    width: 100%;
    height: 50%;
  }

  .right-charts{
    position: absolute;
    right:10px;
    top: 15rem;
    width: 30rem;
    height: 72%;
    z-index: 100;
  }

  ::v-deep .pagination-container{
    height: 50px;
    color:white;
    background: transparent;
  }
  ::v-deep .pagination-container .el-pagination{
    color:white;
  }
  ::v-deep .el-pagination__total,::v-deep .el-pagination__jump{
    color:unset;
  }
</style>


<style lang='scss' scoped>
  @import '@/styles/map.scss';
</style>
